package com.example.consumer.service;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * FeignClient注解的常用属性说明：
 *  name：指定Feign的名称，如果使用了注册中心，name属性会作为微服务的名称，用于服务发现
 *  url：Feign调用的跳转路径，可以在配置文件中设置，多用于代码调试
 */
@FeignClient( name = "provider", url = "${provider-url}")
public interface HelloService {
    @GetMapping(value = "/hello")
    public String hello();

    @GetMapping(value = "/hellowithparams")
    public String hellowithparams(@RequestParam(value = "name") String name);

    @PostMapping(value = "/hellowithparamspost")
    public String hellowithparamspost(@RequestBody HelloUser helloUser);

    public static class HelloUser{
        private String name;

        public HelloUser() {
        }

        public HelloUser(String name) {
            this.name = name;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
